---
<%= lines(autogen_notice :yaml) -%>
# Pre-test setup
<% unless example.dependencies.nil? -%>
<% example.dependencies.each do |depend| -%>
<%= lines(depend.build_test('present', object, false)) -%>
<% end # example.dependencies.each -%>
<% end # if example.dependencies -%>
<%= lines(example.task.build_test('absent', object, false)) -%>
#----------------------------------------------------------
<% resource_name = Google::StringUtils.uncombine(object.name).downcase -%>
<%= lines(example.task.build_test('present', object, false)) -%>
  register: result
<% if object.virtual -%>
- name: assert changed is false
<% else # if object.virtual -%>
- name: assert changed is true
<% end # if object.virtual -%>
  assert:
    that:
<% if object.virtual -%>
      # <%= object.name -%> is not altered, just verified.
      - result.changed == false
<% else # if object.virtual -%>
      result is changed
<% end # if object.virtual -%>
<% if object.kind? -%>
      - "result.kind == <%= quote_string(object.kind) -%>"
<% end # if object.kind -%>
<% unless example.verifier.nil? -%>
<%= lines(example.verifier.build_task('present', object)) -%>
<% end -%>
<% unless object.virtual -%>
# ----------------------------------------------------------------------------
<%= lines(example.task.build_test('present', object, true)) -%>
  register: result
- name: assert changed is false
  assert:
    that:
      - result.failed == 0
      - result.changed == false
<% if object.kind? -%>
      - "result.kind == <%= quote_string(object.kind) -%>"
<% end # if object.kind -%>
#----------------------------------------------------------
<%= lines(example.task.build_test('absent', object, false)) -%>
  register: result
- name: assert changed is true
  assert:
    that:
      result is changed
<% if object.kind? -%>
      - result.has_key('kind') == False
<% end # if object.kind? -%>
<% unless example.verifier.nil? -%>
<%= lines(example.verifier.build_task('absent', object)) -%>
<% end -%>
# ----------------------------------------------------------------------------
<%= lines(example.task.build_test('absent', object, true)) -%>
  register: result
- name: assert changed is false
  assert:
    that:
      - result.failed == 0
      - result.changed == false
<% if object.kind? -%>
      - result.has_key('kind') == False
<% end # if object.kind? -%>
<% end # object.virtual -%>
<% if example.dependencies and !example.dependencies.empty? -%>
#---------------------------------------------------------
# Post-test teardown
<% example.dependencies.reverse.each do |depend| -%>
<%= lines(depend.build_test('absent', object, false)) -%>
<% end # example.dependencies.each -%>
<% end # if example.dependencies -%>
